package tagdb.fasta;


import com.compomics.util.protein.Header;

/**
 * This class represents a FASTA entry.
 *
 * @author Thilo Muth
 */
public class FastaEntry {

    /**
     * The index of the entry.
     */
    private long index;

    /**
     * Name of the entry (ProteinID).
     */
    private String name;

    /**
     * Protein header == accession + description + meta-information (if any).
     */
    private Header header;

    /**
     * Character string of the sequence.
     */
    private String sequence;

    /**
     * Start position of the sequence.
     */
    private int start;

    /**
     * End position of the sequence.
     */
    private int end;


    public FastaEntry() {
    }

    /**
     * Copy Constructor
     *
     * @param entry
     */
    public FastaEntry(FastaEntry entry) {
        this.index = entry.getIndex();
        this.name = entry.getName();
        this.header = entry.getHeader();
        this.sequence = entry.getSequence();
        this.start = entry.getStart();
        this.end = entry.getEnd() ;
    }

    /**
     * Constructor for the entry implementation, where
     * sequence is given as string
     *
     * @param name
     * @param sequence
     * @param start
     * @param end
     */
    public FastaEntry(int index, String name, String sequence, int start, int end) {
        this.index = index;
        this.name = name;
        this.header = Header.parseFromFASTA(name);
        this.sequence = sequence;
        this.start = start;
        this.end = end;
    }

    /**
     * Constructor for the sequence implementation.
     * The whole sequence string is taken from start to end position.
     *
     * @param name
     * @param sequence
     */
    public FastaEntry(int index, String name, String sequence) {
        this(index, name, sequence, 1, -1);
    }

    /**
     * Returns the sequence start position of the sequence.
     */
    public int getStart() {
        return start;
    }

    /**
     * Returns the index of the entry.
     *
     * @return the index of the entry
     */
    public long getIndex() {
        return index;
    }




    /**
     * Returns the end position of the sequence.
     */
    public int getEnd() {
        return this.end;
    }

    /**
     * Returns the sequence length.
     */
    public int getLength() {
        return this.sequence.length();
    }

    /**
     * Returns the sequence name.
     *
     * @return String
     */
    public String getName() {
        return this.name;
    }

    /**
     * Returns the conventional protein header.
     */
    public Header getHeader() {
        return header;
    }

    /**
     * Returns the sequence as char array.
     */
    public String getSequence() {
        return sequence;
    }
}

